home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
docdem.zip
/
LBOXTEST.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-04-09
|
2KB
|
80 lines
{************************************************}
{ }
{ Turbo Pascal for Windows }
{ Demo program }
{ Copyright (c) 1991 by Borland International }
{ }
{************************************************}
program LBoxTest;
uses WObjects, WinTypes, WinProcs;
const
id_LB1 = 101;
type
TestApplication = object(TApplication)
procedure InitMainWindow; virtual;
end;
PTestWindow = ^TestWindow;
TestWindow = object(TWindow)
LB1: PListBox;
constructor Init(AParent: PWindowsObject; ATitle: PChar);
procedure SetupWindow; virtual;
procedure HandleListBoxMsg(var Msg: TMessage);
virtual id_First + id_LB1;
end;
constructor TestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
begin
TWindow.Init(AParent, ATitle);
LB1 := New(PListBox, Init(@Self, id_LB1, 20, 20, 340, 100));
end;
procedure TestWindow.SetupWindow;
begin
TWindow.SetupWindow;
LB1^.AddString('Item 1');
LB1^.AddString('Item 2');
LB1^.AddString('Item 3');
LB1^.InsertString('Item 1.5', 1);
LB1^.AddString('Item 4');
LB1^.AddString('Item 5');
LB1^.AddString('Item 6');
end;
procedure TestWindow.HandleListBoxMsg(var Msg: TMessage);
var
Idx: Integer;
ItemText: array[0..10] of Char;
begin
if Msg.LParamHi = lbn_SelChange then
begin
Idx := LB1^.GetSelIndex;
if LB1^.GetStringLen(Idx) < SizeOf(ItemText) then
begin
LB1^.GetSelString(ItemText, 10);
MessageBox(HWindow, ItemText, 'You selected:', mb_OK);
end;
end
else DefWndProc(Msg);
end;
procedure TestApplication.InitMainWindow;
begin
MainWindow := New(PTestWindow, Init(nil, 'List Box Tester'));
end;
var
TestApp : TestApplication;
begin
TestApp.Init('LBoxTest');
TestApp.Run;
TestApp.Done;
end.